package com.bkq.viettravel;


import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;



import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.ListView;

		/*
		 * author: Hung
		 */
public class FavoritesActivity extends Activity {
    /** Called when the activity is first created. */
	 //lap array list de luu tru danh sach cac thong tin can nhap vao cho list
	 ArrayList<String> travel_name= new ArrayList<String>();
	 ArrayList<String> travel_intro= new ArrayList<String>();
	 ArrayList<String> img_link= new ArrayList<String>();
	 //list
	 public final static String ITEM_TRAVEL_NAME = "travelname";
	 public final static String ITEM_tRAVEL_INTRO = "trvelintro";
	 public final static String ITEM_IMG_LINK = "imagelink";
	 public Map<String,String> createItem(String travelname, String trvelintro, String imagelink) {
	 Map<String,String> item = new HashMap<String,String>();
	 item.put(ITEM_TRAVEL_NAME, travelname);
	 item.put(ITEM_tRAVEL_INTRO, trvelintro);
	 item.put(ITEM_IMG_LINK, imagelink);
	 return item;
	 }
	 
	 
	
	ImageButton  back=null, home=null, favorites=null, plant=null, infor= null;
	ImageView add_comment=null;
	Button hinhanh=null, dv_luhanh=null, chiduong=null;
	int option_selected=0;
	ListView listtravel;
	
    @Override
    public void onCreate(Bundle savedInstanceState) {
    	super.onCreate(savedInstanceState);
        setContentView(R.layout.favorites);
        back = (ImageButton) findViewById(R.id.favorites_btn_back);
        home = (ImageButton) findViewById(R.id.favorites_home);
        favorites = (ImageButton) findViewById(R.id.favorites_favourites);
        plant = (ImageButton) findViewById(R.id.favorites_plant);
        infor = (ImageButton) findViewById(R.id.favorites_information);
        
        
       
        
//bottom bar

        home.setOnClickListener(new OnClickListener()
        {

			public void onClick(View v) {
				// TODO Auto-generated method stub
				
					home.setBackgroundDrawable( getApplicationContext().getResources().getDrawable(R.drawable.icon_trangchinh_selected));
					Intent i = new Intent(FavoritesActivity.this, VietTravelActivity.class);
					startActivity(i);
					
			}

        });
        
/*
        favorites.setOnClickListener(new OnClickListener()
        {

			public void onClick(View v) {
				// TODO Auto-generated method stub
				
				favorites.setBackgroundDrawable( getApplicationContext().getResources().getDrawable(R.drawable.icon_uuthich_selected));
				Intent i = new Intent(FavoritesActivity.this, FavoritesActivity.class);
				startActivity(i);	
				
				
			}

        });*/
        

        plant.setOnClickListener(new OnClickListener()
        {

			public void onClick(View v) {
				// TODO Auto-generated method stub
				
					plant.setBackgroundDrawable( getApplicationContext().getResources().getDrawable(R.drawable.icon_kehoach_selected));
					Intent i = new Intent(FavoritesActivity.this, Plan.class);
					startActivity(i);
					
			}

        });
        

        infor.setOnClickListener(new OnClickListener()
        {

			public void onClick(View v) {
				// TODO Auto-generated method stub
				
				infor.setBackgroundDrawable( getApplicationContext().getResources().getDrawable(R.drawable.icon_thongtin_selected));
				Intent i = new Intent(FavoritesActivity.this, FavoritesActivity.class);
				startActivity(i);	
				
				
			}

        });
        
        //top bar
        
        back.setOnClickListener(new OnClickListener()
        {

			public void onClick(View v) {
				// TODO Auto-generated method stub
				
					back.setBackgroundDrawable( getApplicationContext().getResources().getDrawable(R.drawable.icon_back_selected));
					finish();
				
				
			}

        });
       

        

        listtravel = (ListView) findViewById(R.id.favorites_list);
        
      //Initialize variable
      		try{
      		list_initialize();
      		}
      		catch(Exception ex ) {
      			
      		}
        
    }

	private void list_initialize() {
		// TODO Auto-generated method stub
		
		//lay du lieu
		// Dữ liệu chỉ mang tính chất kiểm tra, sau khi xây dựng database sẻ xây dựng lại
		travel_name.add("Ba na");
		travel_intro.add("chua di chua biet ba na, di roi moi biet o nha van hon");
		img_link.add("http://anh.24h.com.vn/upload/news/2009-12-13/1260718617-du-lich-ba-na-4.jpg");
		travel_name.add("Ba na");
		travel_intro.add("chua di chua biet ba na, di roi moi biet o nha van hon");
		img_link.add("http://anh.24h.com.vn/upload/news/2009-12-13/1260718617-du-lich-ba-na-4.jpg");
		travel_name.add("Ba na");
		travel_intro.add("chua di chua biet ba na, di roi moi biet o nha van hon");
		img_link.add("http://anh.24h.com.vn/upload/news/2009-12-13/1260718617-du-lich-ba-na-4.jpg");
	
	//gan du lieu vua lay vao cac String va truyen vao adapter
	 String[] name_travel=travel_name.toArray(new String[travel_name.size()]);
	 String[] intro_travel=travel_intro.toArray(new String[travel_intro.size()]);
	 String[] img_link_travel=img_link.toArray(new String[img_link.size()]);
	 listtravel.setAdapter(new FavoritesArrayAdapter(this, name_travel,intro_travel,img_link_travel));
	 listtravel.setTextFilterEnabled(true);
	}
    
}
